import Vue from 'vue'
import VueRouter from 'vue-router'
import App from "../App";
import Home from '../views/Home.vue'
import BackHome from "../views/backstage/BackHome"
import GoodsList from "../views/backstage/GoodsList"
import OrderList from "../views/backstage/OrderList"
import UserList from "../views/backstage/UserList";
import Login from "../views/frontstage/Login";
import GoodsClass from "../views/frontstage/GoodsClass";
import Register from "../views/frontstage/Register";
import MyIndex from "../views/frontstage/Myindex";
import EchartsList from "../views/backstage/EchartsList";
import AddGoods from "../views/backstage/AddGoods";
import AddUser from "../views/backstage/AddUser";
import SocialUpload from "../views/backstage/SocialUpload"
import SocialShow from "../views/frontstage/SocialShow"
import SocialMain from "../views/frontstage/SocialMain";
import HeaderNavigation from "../components/HeaderNavigation";
import Details from "../views/frontstage/Details";
import OrderConfirm from "../views/frontstage/OrderConfirm";
import OrderSubmission from "../views/frontstage/OrderSubmission";
import UserOrderList from "../views/backstage/UserOrderList";
import UserOrder from "../views/frontstage/UserOrder";
import Events from "../views/backstage/Events";
import HomeSlideshow from "../views/backstage/HomeSlideshow";
import Boutique from "../views/backstage/Boutique";
import SalesHigh from "../views/backstage/SalesHigh";
import Tideway from "../views/backstage/Tideway";
import TextLeader from "../components/TextLeader";
import IndividualSocialShow from "../views/frontstage/individualSocialShow";
import FuturePart from "../views/backstage/FuturePart";
import CollectionSocialShow from "../views/frontstage/collectionSocialShow"
import SocialDetail from "../components/SocialDetail"
import Alipay from "../views/frontstage/Alipay";
import ApplayText from "../views/frontstage/ApplayText";
import ShopCategory from "../views/frontstage/ShopCategory"
Vue.use(VueRouter);

const router = new VueRouter({
    routes:[
        {
            path: '/',
            name: 'HeaderNavigation',
            component: HeaderNavigation,
            children:[
                {
                    path: '/',
                    component: MyIndex
                },
                {
                    path: 'MyIndex',
                    name: 'MyIndex',
                    component: MyIndex
                },
                {
                    path: 'GoodsClass',
                    name: 'GoodsClass',
                    component: GoodsClass
                },
                {
                    path: 'UserOrder',
                    name: 'UserOrder',
                    component: UserOrder
                },
                {
                    path: 'Details',
                    name: 'Details',
                    component: Details
                },
                {
                    path: 'OrderConfirm',
                    name: 'OrderConfirm',
                    component: OrderConfirm,
                    meta:{
                        needLogin:true  //需要验证登录
                    },
                },
                {
                    path: 'Alipay',
                    name: 'Alipay',
                    component: Alipay,
                },
                {
                    path: 'ApplayText',
                    name: 'ApplayText',
                    component: ApplayText,
                },
                {
                    path: 'OrderSubmission',
                    name: 'OrderSubmission',
                    component: OrderSubmission
                },
                {
                    path:'ShopCategory',
                    name:'ShopCategory',
                    component:ShopCategory
                },
                {
                    path:'FuturePart',
                    name:'FuturePart',
                    component:FuturePart
                }
            ]
        },

        {
            path: '/BackHome',
            name: 'BackHome',
            component: BackHome,
            meta:{
                needLogin:true,  //需要验证登录
                isBackManager:true
            },
            children:[
                {
                    path: '/',
                    redirect:'EchartsList',
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'EchartsList',
                    component: EchartsList,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'GoodsList',
                    component: GoodsList,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'AddGoods',
                    component: AddGoods,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'UserList',
                    component: UserList,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'AddUser',
                    component: AddUser,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },

                },
                {
                    path: 'UserOrderList',
                    component: UserOrderList,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'OrderList',
                    component: OrderList,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'Events',
                    component: Events,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'SalesHigh',
                    component: SalesHigh,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'Boutique',
                    component: Boutique,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'Tideway',
                    component: Tideway,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'HomeSlideshow',
                    component: HomeSlideshow,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'TextLeader',
                    component: TextLeader,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
                {
                    path: 'FuturePart',
                    name: 'FuturePart',
                    component: FuturePart,
                    meta:{
                        needLogin:true,  //需要验证登录
                        isBackManager:true
                    },
                },
            ]
        },
        {
            path: '/App',
            name: 'App',
            component: App
        },
        {
            path: '/home',
            name: 'Home',
            component: Home
        },
        {
            path: '/about',
            name: 'About',
            // route level code-splitting
            // this generates a separate chunk (about.[hash].js) for this route
            // which is lazy-loaded when the route is visited.
            component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
        },
        {
            path: '/login',
            name: 'Login',
            component: Login,
        },
        {
            path: '/register',
            name: 'Register',
            component: Register
        },
        {
          path: '/OrderSubmission',
          name: 'OrderSubmission',
          component: OrderSubmission
        },

        {
            path: '/SocialMain',
            redirect:'/SocialMain/SocialShow',
            name: 'SocialMain',
            component: SocialMain,
            children:[
                {path:'/SocialMain/SocialShow',component:SocialShow},
                {path:'/SocialMain/Socialupload',component:SocialUpload,
                 beforeEnter:(to, from, next) => {
                        if(to.path==='/SocialMain/Socialupload'){
                            const token=window.sessionStorage.getItem('token');
                            if(!token){
                                return next('/login')
                            }else {
                                return next();
                            }
                        }
                    }
                },
                {path:'/SocialMain/IndividualSocialShow',component:IndividualSocialShow,
                    beforeEnter:(to, from, next) => {
                        if(to.path==='/SocialMain/IndividualSocialShow'){
                            const token=window.sessionStorage.getItem('token');
                            if(!token){
                                return next('/login')
                            }else {
                                return next();
                            }
                        }
                    }
                },
                {path:'/SocialMain/CollectionSocialShow',component:CollectionSocialShow,
                    beforeEnter:(to, from, next) => {
                        if(to.path==='/SocialMain/CollectionSocialShow'){
                            const token=window.sessionStorage.getItem('token');
                            if(!token){
                                return next('/login')
                            }else {
                                return next();
                            }
                        }
                    }
                },
                {path:'/SocialMain/SocialDetail',component:SocialDetail,
                    beforeEnter:(to, from, next) => {
                        if(to.path==='/SocialMain/SocialDetail'){
                            const token=window.sessionStorage.getItem('token');
                            if(!token){
                                return next('/login')
                            }else {
                                return next();
                            }
                        }
                    }
                },
            ],
        }
    ]
});

export default router
